from pydantic import BaseModel
from typing import Optional
from datetime import date, datetime

class EmployeeBase(BaseModel):
    """员工基础数据模式"""
    name: str
    gender: int  # 1-男，2-女
    birth_date: date
    phone: str
    department_id: int
    position: str
    id_card: Optional[str] = None
    address: Optional[str] = None
    emergency_contact: Optional[str] = None
    emergency_phone: Optional[str] = None
    remark: Optional[str] = None
    photo_url: Optional[str] = None
    status: int = 1

class EmployeeCreate(EmployeeBase):
    """创建员工时的数据模式"""
    pass

class EmployeeUpdate(BaseModel):
    """更新员工时的数据模式"""
    name: Optional[str] = None
    gender: Optional[int] = None
    birth_date: Optional[date] = None
    phone: Optional[str] = None
    address: Optional[str] = None
    department_id: Optional[int] = None
    position: Optional[str] = None
    status: Optional[int] = None
    emergency_contact: Optional[str] = None
    emergency_phone: Optional[str] = None
    remark: Optional[str] = None
    photo_url: Optional[str] = None

class EmployeeInDB(EmployeeBase):
    """返回给用户的员工数据模式"""
    id: int
    status: int
    photo_url: Optional[str] = None
    photo_update_time: Optional[datetime] = None
    create_time: datetime
    update_time: Optional[datetime] = None

    class Config:
        from_attributes = True 